package edu.tgc.entity.qrtz;

import java.util.Date;
import java.util.UUID;

import javax.persistence.ManyToOne;
import javax.persistence.Transient;

import org.quartz.TriggerKey;

import edu.tgc.entity.system.AbstractPersistableEntity;

public class QrtzTrigger extends AbstractPersistableEntity<UUID> {

    private static final long serialVersionUID = 5694947882902029055L;
    protected String description;
    protected Date endTime;
    protected String expression;

    protected Date finalFireTime;
    protected QrtzGroup group;
    protected Integer intervalInMilliseconds = 0;
    protected QrtzJob job;
    // 执行策略
    protected Integer misfireInstruction;
    protected String name;
    protected Date nextFireTime;

    protected Date previousFireTime;
    // 优先级
    protected Integer priority;
    protected Integer repeatCount = 0;

    protected Date startTime;
    protected String timeZone;

    public String getDescription() {
        return this.description;
    }

    public Date getEndTime() {
        return this.endTime;
    }

    public String getExpression() {
        return this.expression;
    }

    public Date getFinalFireTime() {
        return this.finalFireTime;
    }

    @ManyToOne
    public QrtzGroup getGroup() {
        return this.group;
    }

    public Integer getIntervalInMilliseconds() {
        return this.intervalInMilliseconds;
    }

    @ManyToOne
    public QrtzJob getJob() {
        return this.job;
    }

    public Integer getMisfireInstruction() {
        return this.misfireInstruction;
    }

    public String getName() {
        return this.name;
    }

    public Date getNextFireTime() {
        return this.nextFireTime;
    }

    public Date getPreviousFireTime() {
        return this.previousFireTime;
    }

    public Integer getPriority() {
        return this.priority;
    }

    public Integer getRepeatCount() {
        return this.repeatCount;
    }

    public Date getStartTime() {
        return this.startTime;
    }

    public String getTimeZone() {
        return this.timeZone;
    }

    @Transient
    public TriggerKey getTriggerKey() {
        return new TriggerKey(this.getId().toString(), this.group == null ? null : this.group.getId().toString());
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    public void setExpression(String expression) {
        this.expression = expression;
    }

    public void setFinalFireTime(Date finalFireTime) {
        this.finalFireTime = finalFireTime;
    }

    public void setGroup(QrtzGroup group) {
        this.group = group;
    }

    public void setIntervalInMilliseconds(Integer intervalInMilliseconds) {
        this.intervalInMilliseconds = intervalInMilliseconds;
    }

    public void setJob(QrtzJob job) {
        this.job = job;
    }

    public void setMisfireInstruction(Integer misfireInstruction) {
        this.misfireInstruction = misfireInstruction;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNextFireTime(Date nextFireTime) {
        this.nextFireTime = nextFireTime;
    }

    public void setPreviousFireTime(Date previousFireTime) {
        this.previousFireTime = previousFireTime;
    }

    public void setPriority(Integer priority) {
        this.priority = priority;
    }

    public void setRepeatCount(Integer repeatCount) {
        this.repeatCount = repeatCount;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public void setTimeZone(String timeZone) {
        this.timeZone = timeZone;
    }

}
